layui.define(['jquery','layer','form','element'],function(exports){
    var $ = layui.jquery;
    var  layer = layui.layer;
    var form = layui.form();
    var element = layui.element();

    $("#btn_save").click(function(){
        var id=$("#id").val();
        var oldpass=$("#oldpass").val();
        var npass=$("#npass").val();
        var epass=$("#epass").val();
        if(oldpass==""){layer.msg("原密码不能为空！");return false;}
        if(npass==""){layer.msg("新密码不能为空！");return false;}
        if(epass==""){layer.msg("确认密码不能为空！");return false;}
        if(npass!=epass){layer.msg("两次输入的密码不一样！");return false;}

        $.post("/srv/rdo.php", {tpl:"check_pass",id:id,oldpass:oldpass}, function (d, e) {  
            if(d=="ok"){
                $.post("/srv/rdo.php", {tpl:"update_pass",id:id,npass:npass}, function (d, e) {  
                    if(d=="ok"){
                        layer.msg('修改成功');
                        setTimeout("location.reload()",1000);
                    }else{
                        layer.msg('修改失败');
                    }
                });
            }else{
                layer.msg('原密码不正确！');
                return false;
            }
        });
    });

    exports('uppass', {});
});